#include<iostream>
#include<cstring>
using namespace std;

long long last,n;

int main(){
	cin>>n;
	last=1;
	int tmp;
	for(int i=2;i<=n;i++){
		last=last*i;
		while(last%10==0)last/=10;
		last%=1000000;
	}
	cout<<last%10<<endl;
}